﻿using System;
using System.Collections;
using System.Data.SQLite;
using CSharp.Libs.Koc;

namespace CSharp.Libs.Koc.KernelModels.ItemClasses
{
    public class MarchItem
    {
        #region declarations
        private Int32 _intmarchId = 0;
        private Int32 _inttileId = 0;
        private Int32 _inttileType = 0;
        private Int32 _inttileLevel = 0;
        private Int32 _intinitTS = 0;
        private Double _dbldistance = 0;
        private Int32 _intspeed = 0;
        private Int32 _inteta = 0;
        private Int32 _intdelay = 0;
        private Int32 _intliftFog = 0;
        private Int32 _intatkBoostTime = 0;
        private Int32 _intatk2BoostTime = 0;
        private Int32 _intdefBoostTime = 0;
        private Int32 _intdef2BoostTime = 0;
        private Int32 _intknightCombatBoostTime = 0;
        private Int32 _intmarchUnixTime = 0;
        private Int32 _intreqmicrotime = 0;
        private Int32 _intresmicrotime = 0;
        private Int32 _intCityID = 0;
        private Int32 _intMarchType = 0;
        private Int32 _intKnightID = 0;
        private Int32 _intDestinationXCoord = 0;
        private Int32 _intDestinationYCoord = 0;
        private Int32 _intGold = 0;
        private Int32 _intR1 = 0;
        private Int32 _intR2 = 0;
        private Int32 _intR3 = 0;
        private Int32 _intR4 = 0;
        private String _strItems = "";
        private Int32 _intU1 = 0;
        private Int32 _intU2 = 0;
        private Int32 _intU3 = 0;
        private Int32 _intU4 = 0;
        private Int32 _intU5 = 0;
        private Int32 _intU6 = 0;
        private Int32 _intU7 = 0;
        private Int32 _intU8 = 0;
        private Int32 _intU9 = 0;
        private Int32 _intU10 = 0;
        private Int32 _intU11 = 0;
        private Int32 _intU12 = 0;
        private Int32[] _intUnitCount = new Int32[12] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        private Int32[] _intUnitReturn = new Int32[12] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        private Boolean _fItemChanged = false;
        #endregion



        #region constructor / destructor
        public MarchItem()
        {
        }

        public MarchItem(
            Kernel AB,
            Hashtable htMarch)
        {
            marchId = AB.GetHashtableValue(htMarch, constants.KEY_MARCH_ID, Kernel.VariableTypes.Int32);
            tileId = AB.GetHashtableValue(htMarch, constants.KEY_TILE_ID, Kernel.VariableTypes.Int32);
            tileType = AB.GetHashtableValue(htMarch, constants.KEY_TILE_TYPE, Kernel.VariableTypes.Int32);
            tileLevel = AB.GetHashtableValue(htMarch, constants.KEY_TILE_LEVEL, Kernel.VariableTypes.Int32);
            initTS = AB.GetHashtableValue(htMarch, constants.KEY_INIT_TS, Kernel.VariableTypes.Int32);
            distance = AB.GetHashtableValue(htMarch, constants.KEY_DISTANCE, Kernel.VariableTypes.Double);
            speed = AB.GetHashtableValue(htMarch, constants.KEY_SPEED, Kernel.VariableTypes.Int32);
            eta = AB.GetHashtableValue(htMarch, constants.KEY_ETA, Kernel.VariableTypes.Int32);
            delay = AB.GetHashtableValue(htMarch, constants.KEY_DELAY, Kernel.VariableTypes.Int32);
            liftFog = AB.GetHashtableValue(htMarch, constants.KEY_LIFT_FOG, Kernel.VariableTypes.Int32);
            atkBoostTime = AB.GetHashtableValue(htMarch, constants.KEY_ATK_BOOST_TIME, Kernel.VariableTypes.Int32);
            atk2BoostTime = AB.GetHashtableValue(htMarch, constants.KEY_ATK2_BOOST_TIME, Kernel.VariableTypes.Int32);
            defBoostTime = AB.GetHashtableValue(htMarch, constants.KEY_DEF_BOOST_TIME, Kernel.VariableTypes.Int32);
            def2BoostTime = AB.GetHashtableValue(htMarch, constants.KEY_DEF2_BOOST_TIME, Kernel.VariableTypes.Int32);
            knightCombatBoostTime = AB.GetHashtableValue(htMarch, constants.KEY_KNIGHT_COMBAT_BOOST_TIME, Kernel.VariableTypes.Int32);
            marchUnixTime = AB.GetHashtableValue(htMarch, constants.KEY_MARCH_UNIX_TIME, Kernel.VariableTypes.Int32);
            reqmicrotime = AB.GetHashtableValue(htMarch, constants.KEY_REQ_MICRO_TIME, Kernel.VariableTypes.Int32);
            resmicrotime = AB.GetHashtableValue(htMarch, constants.KEY_RES_MICRO_TIME, Kernel.VariableTypes.Int32);

            CityID = Int32.Parse(AB.UH.URLMarch.Parameters[URLHolder.PARAM_CID].ToString());
            MarchType = Int32.Parse(AB.UH.URLMarch.Parameters[URLHolder.PARAM_TYPE].ToString());
            KnightID = Int32.Parse(AB.UH.URLMarch.Parameters[URLHolder.PARAM_KID].ToString());
            DestinationXCoord = Int32.Parse(AB.UH.URLMarch.Parameters[URLHolder.PARAM_X_COORD].ToString());
            DestinationYCoord = Int32.Parse(AB.UH.URLMarch.Parameters[URLHolder.PARAM_Y_COORD].ToString());
            Gold = Int32.Parse(AB.UH.URLMarch.Parameters[URLHolder.PARAM_GOLD].ToString());
            R1 = Int32.Parse(AB.UH.URLMarch.Parameters[URLHolder.PARAM_R1].ToString());
            R2 = Int32.Parse(AB.UH.URLMarch.Parameters[URLHolder.PARAM_R2].ToString());
            R3 = Int32.Parse(AB.UH.URLMarch.Parameters[URLHolder.PARAM_R3].ToString());
            R4 = Int32.Parse(AB.UH.URLMarch.Parameters[URLHolder.PARAM_R4].ToString());
            Items = AB.UH.URLMarch.Parameters[URLHolder.PARAM_ITEMS].ToString();

            for(Int32 IDX = 0; IDX < 12; IDX++)
            {
                UnitCount[IDX] = AB.UH.URLMarch.GetParameterValueInt32("u" + (IDX + 1).ToString());
            }
        }

        public MarchItem(
            Kernel AB,
            SQLiteDataReader DR)
        {
            marchId = AB.GetObjectValue(DR[constants.KEY_MARCH_ID], Kernel.VariableTypes.Int64);
            tileId = AB.GetObjectValue(DR[constants.KEY_TILE_ID], Kernel.VariableTypes.Int64);
            tileType = AB.GetObjectValue(DR[constants.KEY_TILE_TYPE], Kernel.VariableTypes.Int64);
            tileLevel = AB.GetObjectValue(DR[constants.KEY_TILE_LEVEL], Kernel.VariableTypes.Int64);
            initTS = AB.GetObjectValue(DR[constants.KEY_INIT_TS], Kernel.VariableTypes.Int64);
            distance = AB.GetObjectValue(DR[constants.KEY_DISTANCE], Kernel.VariableTypes.Double);
            speed = AB.GetObjectValue(DR[constants.KEY_SPEED], Kernel.VariableTypes.Int64);
            eta = AB.GetObjectValue(DR[constants.KEY_ETA], Kernel.VariableTypes.Int64);
            delay = AB.GetObjectValue(DR[constants.KEY_DELAY], Kernel.VariableTypes.Int64);
            liftFog = AB.GetObjectValue(DR[constants.KEY_LIFT_FOG], Kernel.VariableTypes.Int64);
            atkBoostTime = AB.GetObjectValue(DR[constants.KEY_ATK_BOOST_TIME], Kernel.VariableTypes.Int64);
            atk2BoostTime = AB.GetObjectValue(DR[constants.KEY_ATK2_BOOST_TIME], Kernel.VariableTypes.Int64);
            defBoostTime = AB.GetObjectValue(DR[constants.KEY_DEF_BOOST_TIME], Kernel.VariableTypes.Int64);
            def2BoostTime = AB.GetObjectValue(DR[constants.KEY_DEF2_BOOST_TIME], Kernel.VariableTypes.Int64);
            knightCombatBoostTime = AB.GetObjectValue(DR[constants.KEY_KNIGHT_COMBAT_BOOST_TIME], Kernel.VariableTypes.Int64);
            marchUnixTime = AB.GetObjectValue(DR[constants.KEY_MARCH_UNIX_TIME], Kernel.VariableTypes.Int64);
            reqmicrotime = AB.GetObjectValue(DR[constants.KEY_REQ_MICRO_TIME], Kernel.VariableTypes.Int64);
            resmicrotime = AB.GetObjectValue(DR[constants.KEY_RES_MICRO_TIME], Kernel.VariableTypes.Int64);
            CityID = AB.GetObjectValue(DR[URLHolder.PARAM_CID], Kernel.VariableTypes.Int64);
            MarchType = AB.GetObjectValue(DR[URLHolder.PARAM_TYPE], Kernel.VariableTypes.Int64);
            KnightID = AB.GetObjectValue(DR[URLHolder.PARAM_KID], Kernel.VariableTypes.Int64);
            DestinationXCoord = AB.GetObjectValue(DR[URLHolder.PARAM_X_COORD], Kernel.VariableTypes.Int64);
            DestinationYCoord = AB.GetObjectValue(DR[URLHolder.PARAM_Y_COORD], Kernel.VariableTypes.Int64);
            Gold = AB.GetObjectValue(DR[URLHolder.PARAM_GOLD], Kernel.VariableTypes.Int64);
            R1 = AB.GetObjectValue(DR[URLHolder.PARAM_R1], Kernel.VariableTypes.Int64);
            R2 = AB.GetObjectValue(DR[URLHolder.PARAM_R2], Kernel.VariableTypes.Int64);
            R3 = AB.GetObjectValue(DR[URLHolder.PARAM_R3], Kernel.VariableTypes.Int64);
            R4 = AB.GetObjectValue(DR[URLHolder.PARAM_R4], Kernel.VariableTypes.Int64);
            Items = AB.GetObjectValue(DR[URLHolder.PARAM_ITEMS], Kernel.VariableTypes.String);

            for (Int32 IDX = 0; IDX < 12; IDX++)
            {
                UnitCount[IDX] = AB.GetObjectValue(DR["u" + (IDX + 1).ToString()], Kernel.VariableTypes.Int64);
            }
        }

        ~MarchItem()
        {
        }
        #endregion



        #region interface
        public Int32 marchId
        {
            get
            {
                return _intmarchId;
            }
            set
            {
                _fItemChanged = true;
                _intmarchId = value;
            }
        }

        public Int32 tileId
        {
            get
            {
                return _inttileId;
            }
            set
            {
                _fItemChanged = true;
                _inttileId = value;
            }
        }

        public Int32 tileType
        {
            get
            {
                return _inttileType;
            }
            set
            {
                _fItemChanged = true;
                _inttileType = value;
            }
        }

        public Int32 tileLevel
        {
            get
            {
                return _inttileLevel;
            }
            set
            {
                _fItemChanged = true;
                _inttileLevel = value;
            }
        }

        public Int32 initTS
        {
            get
            {
                return _intinitTS;
            }
            set
            {
                _fItemChanged = true;
                _intinitTS = value;
            }
        }

        public Double distance
        {
            get
            {
                return _dbldistance;
            }
            set
            {
                _fItemChanged = true;
                _dbldistance = value;
            }
        }

        public Int32 speed
        {
            get
            {
                return _intspeed;
            }
            set
            {
                _fItemChanged = true;
                _intspeed = value;
            }
        }

        public Int32 eta
        {
            get
            {
                return _inteta;
            }
            set
            {
                _fItemChanged = true;
                _inteta = value;
            }
        }

        public Int32 delay
        {
            get
            {
                return _intdelay;
            }
            set
            {
                _fItemChanged = true;
                _intdelay = value;
            }
        }

        public Int32 liftFog
        {
            get
            {
                return _intliftFog;
            }
            set
            {
                _fItemChanged = true;
                _intliftFog = value;
            }
        }

        public Int32 atkBoostTime
        {
            get
            {
                return _intatkBoostTime;
            }
            set
            {
                _fItemChanged = true;
                _intatkBoostTime = value;
            }
        }

        public Int32 atk2BoostTime
        {
            get
            {
                return _intatk2BoostTime;
            }
            set
            {
                _fItemChanged = true;
                _intatk2BoostTime = value;
            }
        }

        public Int32 defBoostTime
        {
            get
            {
                return _intdefBoostTime;
            }
            set
            {
                _fItemChanged = true;
                _intdefBoostTime = value;
            }
        }

        public Int32 def2BoostTime
        {
            get
            {
                return _intdef2BoostTime;
            }
            set
            {
                _fItemChanged = true;
                _intdef2BoostTime = value;
            }
        }

        public Int32 knightCombatBoostTime
        {
            get
            {
                return _intknightCombatBoostTime;
            }
            set
            {
                _fItemChanged = true;
                _intknightCombatBoostTime = value;
            }
        }

        public Int32 marchUnixTime
        {
            get
            {
                return _intmarchUnixTime;
            }
            set
            {
                _fItemChanged = true;
                _intmarchUnixTime = value;
            }
        }

        public Int32 reqmicrotime
        {
            get
            {
                return _intreqmicrotime;
            }
            set
            {
                _fItemChanged = true;
                _intreqmicrotime = value;
            }
        }

        public Int32 resmicrotime
        {
            get
            {
                return _intresmicrotime;
            }
            set
            {
                _fItemChanged = true;
                _intresmicrotime = value;
            }
        }

        public Int32 CityID
        {
            get
            {
                return _intCityID;
            }
            set
            {
                _fItemChanged = true;
                _intCityID = value;
            }
        }

        public Int32 MarchType
        {
            get
            {
                return _intMarchType;
            }
            set
            {
                _fItemChanged = true;
                _intMarchType = value;
            }
        }

        public Int32 KnightID
        {
            get
            {
                return _intKnightID;
            }
            set
            {
                _fItemChanged = true;
                _intKnightID = value;
            }
        }

        public Int32 DestinationXCoord
        {
            get
            {
                return _intDestinationXCoord;
            }
            set
            {
                _fItemChanged = true;
                _intDestinationXCoord = value;
            }
        }

        public Int32 DestinationYCoord
        {
            get
            {
                return _intDestinationYCoord;
            }
            set
            {
                _fItemChanged = true;
                _intDestinationYCoord = value;
            }
        }

        public Int32 Gold
        {
            get
            {
                return _intGold;
            }
            set
            {
                _fItemChanged = true;
                _intGold = value;
            }
        }

        public Int32 R1
        {
            get
            {
                return _intR1;
            }
            set
            {
                _fItemChanged = true;
                _intR1 = value;
            }
        }

        public Int32 R2
        {
            get
            {
                return _intR2;
            }
            set
            {
                _fItemChanged = true;
                _intR2 = value;
            }
        }

        public Int32 R3
        {
            get
            {
                return _intR3;
            }
            set
            {
                _fItemChanged = true;
                _intR3 = value;
            }
        }

        public Int32 R4
        {
            get
            {
                return _intR4;
            }
            set
            {
                _fItemChanged = true;
                _intR4 = value;
            }
        }

        public String Items
        {
            get
            {
                return _strItems;
            }
            set
            {
                _fItemChanged = true;
                _strItems = value;
            }
        }

        public Int32 U1
        {
            get
            {
                return _intU1;
            }
            set
            {
                _fItemChanged = true;
                _intU1 = value;
            }
        }

        public Int32 U2
        {
            get
            {
                return _intU2;
            }
            set
            {
                _fItemChanged = true;
                _intU2 = value;
            }
        }

        public Int32 U3
        {
            get
            {
                return _intU3;
            }
            set
            {
                _fItemChanged = true;
                _intU3 = value;
            }
        }

        public Int32 U4
        {
            get
            {
                return _intU4;
            }
            set
            {
                _fItemChanged = true;
                _intU4 = value;
            }
        }

        public Int32 U5
        {
            get
            {
                return _intU5;
            }
            set
            {
                _fItemChanged = true;
                _intU5 = value;
            }
        }

        public Int32 U6
        {
            get
            {
                return _intU6;
            }
            set
            {
                _fItemChanged = true;
                _intU6 = value;
            }
        }

        public Int32 U7
        {
            get
            {
                return _intU7;
            }
            set
            {
                _fItemChanged = true;
                _intU7 = value;
            }
        }

        public Int32 U8
        {
            get
            {
                return _intU8;
            }
            set
            {
                _fItemChanged = true;
                _intU8 = value;
            }
        }

        public Int32 U9
        {
            get
            {
                return _intU9;
            }
            set
            {
                _fItemChanged = true;
                _intU9 = value;
            }
        }

        public Int32 U10
        {
            get
            {
                return _intU10;
            }
            set
            {
                _fItemChanged = true;
                _intU10 = value;
            }
        }

        public Int32 U11
        {
            get
            {
                return _intU11;
            }
            set
            {
                _fItemChanged = true;
                _intU11 = value;
            }
        }

        public Int32 U12
        {
            get
            {
                return _intU12;
            }
            set
            {
                _fItemChanged = true;
                _intU12 = value;
            }
        }

        public Int32[] UnitCount
        {
            get
            {
                return _intUnitCount;
            }
            set
            {
                _intUnitCount = value;
            }
        }

        public Int32[] UnitReturn
        {
            get
            {
                return _intUnitReturn;
            }
            set
            {
                _intUnitReturn = value;
            }
        }

        public Boolean ItemChanged
        {
            get
            {
                return _fItemChanged;
            }
            set
            {
                _fItemChanged = value;
            }
        }
        #endregion
    }
}
